package com.lee.datastructures.tree;


/**
 * @Description TODO
 * @Author winston
 * @DateTime 2022/5/11
 */
public class BSTreeTest {
    public static void main(String[] args) {
//        BSTree<Integer> tree = new BSTree<>();
////        Integer[] arr = {1, 5, 4, 3, 2, 6};
//        Integer[] arr = {50, 30, 20, 10, 25, 40, 35, 45, 70, 60, 55, 80, 75};
//        for (Integer i : arr) {
//            tree.insert(i);
//        }
//        // 前序遍历, 打印结果和插入顺序一致.
//        System.out.print("前序遍历: ");
//        tree.preOrder();
//        // 中序遍历, 呈现自然顺序
//        System.out.print("中序遍历: ");
//        tree.inOrder();
//        // 后序遍历,
//        System.out.print("后序遍历");
//        tree.postOrder();
//
//        BSTree<Integer>.BSTNode<Integer> min = tree.min();
//        System.out.println("min value: " + min.value);
//        BSTree<Integer>.BSTNode<Integer> max = tree.max();
//        System.out.println("max value: " + max.value);

//        tree.deleteNode(8);
//        tree.inOrder();

        int i = minDeletionSize(new String[]{"zyx","wvu","tsr"});
        System.out.println(i);
        System.out.println('a'<'c');
    }



    public static int minDeletionSize(String[] strs) {
        int sum=0;
        int length = strs[0].length();
        for(int i=0;i<length;i++){

            for (int j = 1; j < strs.length; j++) {
                char prev = strs[j-1].charAt(i);
                char cur = strs[j].charAt(i);
                if (cur < prev) {
                    sum++;
                    break;
                }
            }
        }
        return sum;
    }


    public static boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        }
        if ((p == null && q != null) || (q != null && p == null)) {
            return false;
        }

        if (!isSameTree(p.left, q.left)) {
            return false;
        }
        if (!isSameTree(p.right, q.right)) {
            return false;
        }
        return true;

    }

    public class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }


    /**
     * 最大深度, 找到所有叶子节点, 计算到根的长度, 取最大值, 叶子节点, left == right ==null;
     *
     * @param root 根
     * @return int
     */
    int result = 0;
    public int maxDepth(TreeNode root) {

        if (root == null) {

        }
        return 0;
    }

}
